package com.room.room.controller;

import java.util.Arrays;
import java.util.Map;

import com.project.utils.PageUtils;
import com.project.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.room.room.entity.HouseRentEntity;
import com.room.room.service.HouseRentService;




/**
 * 
 *
 * @author brh
 * @email sunlightcs@gmail.com
 * @date 2022-03-23 16:10:46
 */
@RestController
@RequestMapping("room/houserent")
public class HouseRentController {
    @Autowired
    private HouseRentService houseRentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = houseRentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{houseId}")
    public R info(@PathVariable("houseId") Integer houseId){
		HouseRentEntity houseRent = houseRentService.getById(houseId);

        return R.ok().put("houseRent", houseRent);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HouseRentEntity houseRent){
		houseRentService.save(houseRent);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HouseRentEntity houseRent){
		houseRentService.updateById(houseRent);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] houseIds){
		houseRentService.removeByIds(Arrays.asList(houseIds));

        return R.ok();
    }

}
